1 Things to know

The topic is trending in the USA. There has been high intensity Mass Shootings in 2017. The analysis may provide information for debates on Immigration, gun laws, mental health issues and drug use. This analysis is limited to Mass Shootings, Other crimes like vehicles as weapons, assassination, homicide and bombings are not visualized.

#Introduction In this Project, The USA mas shooting dataset is used to analyze information about the shooter with respect to Race, States, Causes and Targets.

#Libraries The libraries used are

library(data.table) #Creating data frames
library(shiny) #Creating a front end, but didn't use it here because the app works locally on my system. 
library(lubridate) #For dates
library(plotly) #For plots
library(tidyverse) #To reshape data
library(readr) # To read csv files
library(tidyr) #To reshape data
library("leaflet") #For Maps

#Data The dimensions and Head are shown below

#Formatting Date 
Dateformat = cols(Date = col_date(format = "%m/%d/%Y"))

#Reading Data
Mass_Shootings_Dataset_Ver_5 <- read_csv("Mass Shootings Dataset Ver 5.csv"
                              , col_types = Dateformat)

#Allocating data to a Data Frame
Crime <- data.table(Mass_Shootings_Dataset_Ver_5)

#Dimensions of the dataset
dim(Crime)
## [1] 323  21
#Headers of the dataset
head(Crime)
##    S#                               Title               Location       Date
## 1:  1          Texas church mass shooting Sutherland Springs, TX 2017-11-05
## 2:  2 Walmart shooting in suburban Denver           Thornton, CO 2017-11-01
## 3:  3     Edgewood businees park shooting           Edgewood, MD 2017-10-18
## 4:  4       Las Vegas Strip mass shooting          Las Vegas, NV 2017-10-01
## 5:  5          San Francisco UPS shooting      San Francisco, CA 2017-06-14
## 6:  6   Pennsylvania supermarket shooting        Tunkhannock, PA 2017-06-07
##                                  Incident Area Open/Close Location    Target
## 1:                                      Church               Close    random
## 2:                                    Wal-Mart                Open    random
## 3:                            Remodeling Store               Close coworkers
## 4: Las Vegas Strip Concert outside Mandala Bay                Open    random
## 5:                                UPS facility               Close coworkers
## 6:                                Weis grocery               Close coworkers
##        Cause
## 1:   unknown
## 2:   unknown
## 3:   unknown
## 4:   unknown
## 5:      <NA>
## 6: terrorism
##                                                                                                                                                                                                                                                                                                                                          Summary
## 1:                                                                                                                                                                                     Devin Patrick Kelley, 26, an ex-air force officer, shot and killed 26 people and wounded 20 at a church in Texas. He was found dead later in his vehicle.
## 2:                  Scott Allen Ostrem, 47, walked into a Walmart in a suburb north of Denver and fatally shot two men and a woman, then left the store and drove away. After an all-night manhunt, Ostrem, who had financial problems but no serious criminal history, was captured by police after being spotted near his apartment in Denver.
## 3: Radee Labeeb Prince, 37, fatally shot three people and wounded two others around 9am at Advance Granite Solutions, a home remodeling business where he worked near Baltimore. Hours later he shot and wounded a sixth person at a car dealership in Wilmington, Delaware. He was apprehended that evening following a manhunt by authorities.
## 4:                                                                                                                                     Stephen Craig Paddock, opened fire from the 32nd floor of Manadalay Bay hotel at Last Vegas concert goers for no obvious reason. He shot himself and died on arrival of law enforcement agents. He was 64
## 5:                                                                                                                                                             Jimmy Lam, 38, fatally shot three coworkers and wounded two others inside a UPS facility in San Francisco. Lam killed himself as law enforcement officers responded to the scene.
## 6:                                                                             Randy Stair, a 24-year-old worker at Weis grocery fatally shot three of his fellow employees. He reportedly fired 59 rounds with a pair of shotguns before turning the gun on himself as another co-worker fled the scene for help and law enforcement responded.
##    Fatalities Injured Total victims Policeman Killed Age Employeed (Y/N)
## 1:         26      20            46                0  26              NA
## 2:          3       0             3                0  47              NA
## 3:          3       3             6                0  37              NA
## 4:         59     527           585                1  64              NA
## 5:          3       2             5                0  38               1
## 6:          3       0             3               NA  24               1
##              Employed at Mental Health Issues  Race Gender Latitude Longitude
## 1:                  <NA>                   No White      M       NA        NA
## 2:                  <NA>                   No White      M       NA        NA
## 3: Advance Granite Store                   No Black      M       NA        NA
## 4:                  <NA>              Unclear White      M 36.18127 -115.1341
## 5:                  <NA>                  Yes Asian      M       NA        NA
## 6:          Weis grocery              Unclear White      M       NA        NA

#Pre-Processing Data. For detailed explanation check out my other work called Analysis based on Race, Gender, Cause and Targets.

#Pre-processing Race
Crime[Race=="unclear",Race:="Unknown"]
Crime[is.na(Race),Race:="Other"]
Crime[ Race=="black" | Race=="Black American or African American" | Race=="Black American or African American/Unknown",Race:="Black"]
Crime[Race=="white" | Race=="White American or European American" | Race=="White American or European American/Some other Race" ,Race:="White"]
Crime[Race=="Asian American"| Race=="Asian American/Some other race" ,Race:="Asian"]
Crime[Race=="Unknown"|Race=="Two or more races" | Race=="Some other race",Race:="Other"]

#Pre-processing Date
Crime[,Month:=as.factor(month(Date))]
Crime[,Day:=as.factor(day(Date))]
Crime[,Year:=as.factor(year(Date))]

#Pre-processing Gender
Crime[Gender=='M',Gender:="Male"]
Crime[Gender=='M/F',Gender:="Male/Female"]
Crime[is.na(Gender),Gender:="Unknown"]

#Pre-processing Cause
Crime[is.na(Cause)|Cause=="unknown",Cause:="Unknown"]
Crime[Cause=='domestic dispute'|Cause=='domestic disputer', Cause:='domestic dispute']
Crime[Cause=="anger"|Cause=="frustration",Cause:="Anger and Fustration"]
Crime[Cause=="failing exams" | Cause=="suspension", Cause:="Failing exams and suspension"]

#Pre-processing Target
Crime[is.na(Target),Target:="Unknown"]
Crime[Target=='Family'|Target=='Family/Neighbors'|Target=='Family+students'|Target=='Coworkers'|Target=='coworkers'
|Target=='Students+Parents'|Target=='Family+random'|Target=="partner's family"|Target=="Coworker's Family"
|Target=='neighbors'|Target=='Girlfriend'|Target=="House Owner"
|Target=="Friends",Target:="Family,Girlfriend(Relationships at that time)"]

Crime[Target=='Children'|Target=='school girls'|Target=='Students'
|Target=='Students+Teachers'|Target=='Teachers',Target:="School(Teachers or Students)"] 

Crime[Target=='Ex-Girlfriend'|Target=='Ex-Wife & Family'|Target == 'Ex-Girlfriend & Family' |Target == 'Ex-GirlFriend'
|Target=='Ex-Girlfriend+random'|Target=='Ex-girlfriend'|Target=="Ex-Coworkers"|Target=='Ex-Wife'|Target=='Ex-Girlfriend', Target:="Girlfriend/Wife/coworkers ( past relationships)"]

Crime[Target=='Sikhs'|Target=='monks'|Target=='prayer group',Target:="Motives against religion"] 

Crime[Target=="Marines"|Target=="Policeman+Council Member"| Target=="police"|
Target=="Policeman"|Target=="Trooper"|Target=="Social Workers", Target:="Marines,Police and Social Workers(Police Brutality)"]

Crime[Target=="birthday party bus"|Target=="party guests"|Target=="uninvited guests", Target:="Parties"]

#Pre-processing Mental Health Issues
Crime[`Mental Health Issues`=="unknown",`Mental Health Issues`:="Unknown"]

#Pre-processing Age
Crime[is.na(Age),Age:=0]
NewAge <-
sapply(Crime$Age,function(x){
if(x>=10 && x<20){
"10+ Teen" }
else if(x>=20 && x<30){
"20's"}
else if(x>=30 && x<40){
"30's"}
else if(x>=40 && x<50){
"40's"}
else if(x>=50 && x<60){
"50's"}
else if(x>=60 && x<70){
"60's"}
else if(x>=70 && x<80){
"70's"}
else if(x>80){
"Multiple Shooters"}
else{
"Age Unknown"}
})

#Pre-processing State
Crime$State <- sapply(Crime$Location, function(parts)
        {
            temp <- strsplit(parts, split = ",")
            sapply(temp, function(new)
                {   
                    new[2]
    
                }
                  )
        })

Crime$City <- sapply(Crime$Location, function(parts)
        {
            temp <- strsplit(parts, split = ",")
            sapply(temp, function(new)
                {   
                    new[1]
    
                }
                  )
        })

Crime[is.na(`State`), `State`:="Unknown"]
Crime[`State`==' CA'| `State`== ' San Diego'| `State`==" LA" |`State`== " California", `State`:="California"]
Crime[`State`==' NV'| `State`==" Nevada",`State`:="Nevada"]
Crime[`State`==' CO'| `State` == " Colorado",`State`:="Colorado"] 
Crime[`State`=='  Virginia'|`State`==" Virginia",`State`:="Virginia"]
Crime[`State`==" TX"| `State` == " Texas",`State`:="Texas"]
Crime[`State`==" MD",`State`:="Maryland"]
Crime[`State`==" PA"|`State`==" Lancaster"|`State`==" Souderton",`State`:="Pennsylvania"]
Crime[`State`==" WA"|`State`==" Washington",`State`:="Washington"]


#Preprocessing Map Data
KnownLocations = Crime %>% drop_na(Latitude) %>% drop_na(Longitude)

colmap <- colorFactor(topo.colors(9), Crime$Race)
colgen <- colorFactor(topo.colors(6), Crime$Gender)

Data after preprocessing

1.1 Modified Gender, Race and Mental Health Issues

table(Crime$Race)
## 
##                            Asian                            Black 
##                               18                               85 
##                           Latino Native American or Alaska Native 
##                                5                                3 
##                            Other                            White 
##                               68                              144
table(Crime$`Mental Health Issues`)
## 
##      No Unclear Unknown     Yes 
##      93      13     111     106
table(Crime$Gender)
## 
##      Female        Male Male/Female     Unknown 
##           5         292           5          21

1.2 Frequency in Day Month and Year

table(Crime$Day)
## 
##  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
## 16  8  7  3 11 20 21  7 12  8 10 12  4  9  9  9  9  7 16 15 14  5 10 14 11 11 
## 27 28 29 30 31 
##  8  8 14  9  6
table(Crime$Month)
## 
##  1  2  3  4  5  6  7  8  9 10 11 12 
## 28 53 42 34 19 18 16 22 16 24 22 29
table(Crime$Year)
## 
## 1966 1971 1972 1974 1976 1979 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 
##    2    1    1    2    2    2    2    2    3    2    3    1    6    3    1    5 
## 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 
##    4    9    4    4    3    6    5    7    1    2    2    3    2    3    7   10 
## 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 
##    6    8    2    6   15   16   14   67   69   10

1.3 Modified Age and State

table(NewAge)
## NewAge
##          10+ Teen              20's              30's              40's 
##                38                43                36                41 
##              50's              60's              70's       Age Unknown 
##                11                 3                 1               145 
## Multiple Shooters 
##                 5
table(Crime$State)
## 
##         Alabama          Alaska     Albuquerque         Arizona        Arkansas 
##               9               1               1              11               2 
##     Connecticut         Florida         Georgia          Hawaii           Idaho 
##               3              20              13               1               1 
##        Illinois         Indiana            Iowa          Kansas        Kentucky 
##               9               1               1               4               5 
##       Louisiana           Maine   Massachusetts        Michigan       Minnesota 
##               4               1               4               6               4 
##     Mississippi        Missouri         Montana        Nebraska      New Jersey 
##               4               3               2               3               3 
##      New Mexico        New York  North Carolina            Ohio        Oklahoma 
##               2              10              11              10               5 
##          Oregon    Pennsylvania  South Carolina    South Dakota       Tennessee 
##               4               6               5               1               5 
##            Utah         Vermont   West Virginia       Wisconsin         Wyoming 
##               2               1               1               9               1 
##      California        Colorado        Maryland          Nevada    Pennsylvania 
##              32               7               1               6               3 
##           Texas         Unknown        Virginia      Washington 
##              18              46               6              15

1.4 Modified Cause and Target columns

table(Crime$Cause)
## 
##         Anger and Fustration                      breakup 
##                           62                            1 
##             domestic dispute                        drunk 
##                           13                            1 
## Failing exams and suspension                       psycho 
##                            4                           68 
##                       racism         religious radicalism 
##                            6                            1 
##                      revenge                      robbery 
##                           10                            1 
##                    terrorism                unemployement 
##                           65                           10 
##                      Unknown 
##                           81
table(Crime$Target)
## 
##                                  basketball players 
##                                                   1 
##                                           black men 
##                                                   1 
##                                        club members 
##                                                   1 
##                                       Congresswoman 
##                                                   1 
##                                          Contestant 
##                                                   1 
##                                         drug dealer 
##                                                   1 
##       Family,Girlfriend(Relationships at that time) 
##                                                  73 
##     Girlfriend/Wife/coworkers ( past relationships) 
##                                                  25 
##                                             hunters 
##                                                   1 
##                                             lawyers 
##                                                   1 
## Marines,Police and Social Workers(Police Brutality) 
##                                                  13 
##                            Motives against religion 
##                                                   3 
##                                             Parties 
##                                                  10 
##                                          postmaster 
##                                                   1 
##                                          protestors 
##                                                   1 
##                           psychologist+psychiatrist 
##                                                   1 
##                                              random 
##                                                 140 
##                                       rapper+random 
##                                                   1 
##                        School(Teachers or Students) 
##                                                  39 
##                                         TSA Officer 
##                                                   1 
##                                             Unknown 
##                                                   5 
##                              welding shop employees 
##                                                   1 
##                                               women 
##                                                   1

#Plots with respect to Race

1.5 Incidents with respect to Race

Key Notes: 1) People whose Race is white has the highest number of incidents - 144 2) People whose Race is Native American has the least incidents that is 3

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Race
        )%>% 
  layout(title = "Number of incidents by Race"
         , xaxis = list(title = "Race"))

1.5.1 Races with Mental Health Issues

Key Notes: 1) 71 of the 144 white suspects have mental health problems 2) 30 of the 85 black suspects didnt have mental health issues 3) A lot of data related to people of other races is unknown

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Race
        ,color =~`Mental Health Issues`) %>% 
layout(title = "Total incidents by Race with respect to Mental Health Issue"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Race")
         , legend = list(x = 0, y = 1)
         , hovermode = 'compare')

1.5.2 Map of Races

The goal of this map is to visualize the race of the shooter in different states. For example the race of the shooter in Alaska is White and Hawaii is Asian. The circles indicate the intensity of the shooting which in this case are Fatalities

  KnownLocations %>%
                 leaflet() %>%
                 addTiles() %>%
                 addProviderTiles(providers$Esri.NatGeoWorldMap) %>%
                 addCircles(color=~colmap(Race),lng = ~Longitude, lat = ~Latitude,radius = ~sqrt(`Fatalities`) *50000,label=~Race)

1.6 Races with Gender

Key notes: 1) Its mostly Men of all races that are suspects

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Race
        ,color =~`Gender`) %>% 
layout(title = "Total incidents by Race with respect to Gender"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Race")
         , legend = list(x = 0, y = 1)
         , hovermode = 'compare')

1.6.1 Scatter Map for Better UnderStanding

There are 4 incidents by white female shooters the last being on Feb 2010 in Huntsville Alabama

plot_ly(data = Crime
 ,type = 'scatter'
 ,mode = 'markers' 
 ,hoverinfo = 'text'
 ,x = ~Gender
 ,y = ~Year
 ,size = ~`Fatalities`
 ,text = ~paste(' Date: ', Date 
                ,'\n Location : ', Location 
        ,'\n Total victims :', `Total victims`
        ,'\n Race :', `Race`
                )) %>% 
layout(title = "Mass Shootings in US by Gender"
            , xaxis = list(title = "Gender")
           , yaxis = list(title = "Year"))

1.6.2 Gender Map

This is a map to visualize the gender of the Shooter

KnownLocations %>%
leaflet() %>%
addTiles() %>%
addProviderTiles("OpenStreetMap.HOT") %>%
addCircles(color=~colgen(Gender),lng = ~Longitude, lat = ~Latitude,radius = ~sqrt(`Fatalities`) * 45000,label=~Gender)

1.7 Races with Age

Key Notes: 1) 24 out of the 144 white shooters are teenagers 2) 26 of the 144 white shooters are in their 20’s
3) 21 of the 144 white shooters are in their 40’s

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Race
        ,color =~`NewAge`) %>% 
  layout(title = "Total incidents by Race with respect to Age"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Race")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.7.1 Age Count

145 shooters age is unknown

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`NewAge`)%>% 
layout(title = "Number of incidents by Age"
         , xaxis = list(title = "Age")
         , yaxis = list(title = ""))

1.8 Races with Cause and Target

1.8.1 Cause details

  1. 41 shooters of 144 white are psychos, 26 had anger issues and 27 were terrorists. 2)17 of the 80 Black shooters were terrorists, 18 had anger issues and 14 were psychos.
plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Race
        ,color =~`Cause`) %>% 
layout(title = "Total incidents by Race with respect to Cause"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Race")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.8.2 Target Details

  1. 35 of the 144 white shooters targeted Family,Girlfriend and Coworkers
  2. 24 of the white shooters targetted schools.
  3. 140 incidents were random targets and 56 white, 40 black and 32 people of other races were involved
plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Target
        ,color =~`Race`) %>% 
layout(title = "Total incidents by Race with respect to Target"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Race")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

#Analysis on State

1.9 Incidents Analysis in State

1.9.1 States with Incidents

California, Texas and Florida have a high number of Mass Shootings, I think it’s because there state have more polulation hence more shooters. Also these states have a coast or maybe it’s the hot weather. (I dont know about the gun laws)

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`) %>% 
layout(title = "Number of incidents by State"
         , xaxis = list(title = "Year"))

1.9.2 Victims in State

Nevada is considered an Anomaly because without the Vegas Mass Shooting in 2017. The state didn’t have many incidents

plot_ly(data = Crime[,.('Total victims'= sum(`Total victims`)),by=.(`State`)]
        ,type = 'bar'
        ,x = ~`State`
        ,y = ~`Total victims`) %>% 
layout(title = "Total victims by State"
         , barmode = 'stack'
         , xaxis = list(title = "State")
         , yaxis = list(title = "Victims")
         , legend = list(x = 0, y = 1)
         , hovermode = 'compare')

1.9.3 State Cluster Map

This map shows clusters, As you zoom in you can break it down to states and cities.

KnownLocations %>%
                 leaflet() %>%
                 addTiles() %>%
                 addProviderTiles("OpenStreetMap.HOT")%>%
                 addMarkers(lng = ~Longitude, lat = ~Latitude,clusterOptions = markerClusterOptions(), label=~Location) 

1.10 State analyis based on Gender and Mental Health Issues

1.10.1 State with Gender

California, Illinois and Alabama have female shooters. Florida,California, Nevada and Washington have had multiple shooters

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`
        ,color =~`Gender`) %>% 
  layout(title = "Total incidents by State with respect to Gender"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "State")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.10.2 State with Mental Health Issues

California has the highest number of incidents with shooters having mental illness, followed by Washington. Reasons for Mental Health Issues according to me are, bullying in school, Living upto the standards of society, easy access to drugs which affects the brain’s reward system, and social media (when people stop interacting with each other and lose touch with reality). Washington because of the weather I guess. More details in the state causes and targets graphs Question - How did they obtain guns?

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`
        ,color =~`Mental Health Issues`) %>% 
  layout(title = "Total incidents by State with respect to Mental Health"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "State")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.10.3 Scatter map for Mental Health Issues

plot_ly(data = Crime
        ,type = 'scatter'
        ,mode = 'markers' 
        ,hoverinfo = 'text'
        ,x = ~Year
        ,y = ~State
        ,size = ~`Total victims`
        ,color = ~`Mental Health Issues`
        ,colors = c('Green','Black','Blue','Red')
        ,text = ~paste("Location: ", Location
                       ,'\n Date: ', Date 
                       ,'\n Total victims : ', `Total victims` 
                       ,'\n Race: ', Race)) %>% 
    layout(title = "Mass Shootings in US with year and state"
           , xaxis = list(title = "Years")
           , yaxis = list(title = "States"))
## Warning: `line.width` does not currently support multiple values.

## Warning: `line.width` does not currently support multiple values.

## Warning: `line.width` does not currently support multiple values.

## Warning: `line.width` does not currently support multiple values.

1.11 Analysis on State with respect to Race and Age

1.11.1 State with Race

California has the highest number of White shooters and Florida has the highest number of Black shooters

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`
        ,color =~`Race`) %>% 
  layout(title = "Total victims by State with respect to Race"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "State")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.11.2 State with Age

9 Shooters in California were in their 40’s and 5 Shooters in Texas are in thier 30’s. Washington State have 6 shooters in their 20’s.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`
        ,color =~`NewAge`) %>% 
  layout(title = "Total incidents by State with respect to Age"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "State")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.12 State analysis with respect to Cause and Target

1.12.1 State with Cause

California has the Highest number of Psychos and terrorist shooters. 6 psychos in Georgia and 6 terrorist attacks in Florida

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`
        ,color =~`Cause`) %>% 
  layout(title = "Total incidents by State with respect to Cause"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "State")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.12.2 State with Targets

Schools and Family/girlfriends(At the time of shooting) were one of the top targets for shooters in California. This may explain the mental health issues. 7 shooters in Georgia target people such as their Family, Girlfriend, coworkers at the time of shooting.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`State`
        ,color =~`Target`) %>% 
  layout(title = "Total incidents by State with respect to Target"
         , showlegend = F
         , barmode = 'stack'
         , xaxis = list(title = "State")
    , hovermode = 'compare')

#Analysis on Cause

1.13 Incidents by Causes

Terrorism, Anger and Psycho were the main causes of Shooting.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Cause) %>% 
layout(title = "Number of incidents by Cause"
         , xaxis = list(title = "Cause"))

1.14 Total victims by Causes

plot_ly(data = Crime[,.('Total victims'= sum(`Total victims`)),by=.(`Cause`)]
        ,type = 'bar'
        ,x = ~`Cause`
        ,y = ~`Total victims`) %>% 
layout(title = "Total victims by Cause"
         , barmode = 'stack'
         , xaxis = list(title = "Cause")
         , yaxis = list(title = "Victims")
         , hovermode = 'compare')

1.15 Incidents by Targets

Random Targets, Schools, families and people from the past were the main targets of shooting.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Target)%>% 
  layout(title = "Number of incidents by Target"
         , xaxis = list(title = "Target"))

1.16 Total victims by Targets

plot_ly(data = Crime[,.('Total victims'= sum(`Total victims`)),by=.(`Target`)]
        ,type = 'bar'
        ,x = ~`Target`
        ,y = ~`Total victims`) %>% 
layout(title = "Total victims by Target"
        , barmode = 'stack'
         , xaxis = list(title = "Target")
         , yaxis = list(title = "Victims")
         , hovermode = 'compare')

1.17 Cause by Age

Most Psychos were in their 40’s and most terrorists were in their 20’s

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`Cause`
        ,color =~`NewAge`) %>% 
  layout(title = "Total incidents by Cause with respect to Age"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Cause")
     , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.18 Cause by Gender

Females are mostly Terrorists or Psychos

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`Cause`
        ,color =~`Gender`) %>% 
  layout(title = "Total incidents by Cause with respect to Gender"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Cause")
     , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.19 Target by Age

Highlights: 21 Shooters who were teenagers targeted Schools, 16 Shooters in their 40’s targeted Families/Girlfriends and coworkers at the time of shooting. and 9 shooters in their 40’s targetted people from the past.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`Target`
        ,color =~`NewAge`) %>% 
  layout(title = "Total incidents by Target with respect to Age"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Target")
     , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

1.20 Target by Gender

Females mostly target schools and family

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`Target`
        ,color =~`Gender`) %>% 
  layout(title = "Total incidents by Target with respect to Gender"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Target")
     , legend = list(x = 1, y = 1)
         , hovermode = 'compare')

#Other Analysis

1.21 Date Analysis

1.21.1 Frequency in Year

Based on the histogram we can see that the number of mass shootings is on the rise since 2012

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Year) %>% 
layout(title = "Number of incidents by Year"
         , xaxis = list(title = "Year")) 

1.21.2 Victims in Year

plot_ly(data = Crime[,.('Total victims'= sum(`Total victims`)),by=.(Year)]
        ,type = 'bar'
        ,x = ~Year
    ,y = ~`Total victims` ) %>% 
layout(title = "Number of victims by Year"
         , barmode = 'stack'
         , xaxis = list(title = "Year")
    ,yaxis= list(title = "Total victims"))

1.21.3 Frequency in Month

Most incidents happen during Spring season.

plot_ly(data = Crime[,,by:=(Month)]
        ,type = 'histogram'
        ,x = ~Month)%>% 
  layout(title = "Number of incidents by Month"
         , xaxis = list(title = "Month")) 
## Warning in `[.data.table`(Crime, , , `:=`(by, (Month))): Ignoring by= because j=
## is not supplied

1.21.4 Frequency in Day

For the superstitious people, 4TH day of the month is the safest and 7th is the worst day of the month

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Day)%>% 
  layout(title = "Number of incidents by Day"
         , xaxis = list(title = "Day")) 

1.22 Frequency in Gender

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~Gender) %>% 
layout(title = "Number of incidents by Gender"
         , xaxis = list(title = "Gender"))

1.23 Frequency in Mental Health Issues

There are 106 shooters with mental Health issues, there are 93 shooters with no mental health issues.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`Mental Health Issues`)%>% 
  layout(title = "Number of incidents by Mental Health"
         , xaxis = list(title = "Mental Health Issues"))

1.24 Age with mental health issues

Most shooters between the age of 10-40 have Mental Health Issues.

plot_ly(data = Crime
        ,type = 'histogram'
        ,x = ~`NewAge`
        ,color =~`Mental Health Issues`) %>% 
  layout(title = "Total Incidents by Age with respect to Mental Health Issue"
         , showlegend = T
         , barmode = 'stack'
         , xaxis = list(title = "Age")
         , legend = list(x = 1, y = 1)
         , hovermode = 'compare')